package dome5;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description: 时间复杂度课后习题
 * User: 王圆豪
 * Date: 2024-07-06
 * Time: 22:56
 */
class Solution {
    public static void rotate(int[] nums, int k) {
        for (int i = 0; i < k; i++) {
            int a = nums[nums.length - 1];
            for (int j = nums.length - 1; j > 0; j--) {
                nums[j] = nums[j - 1];
            }
            nums[0] = a;
        }
    }
    public static void main(String[] args) {
        int k = 3;
        int[] nums = new int[]{1,2,3,4,5,6,7};
        rotate(nums, k);
        System.out.println(Arrays.toString(nums));
    }
    public static int missingNumber(int[] nums) {
        int add = nums.length;
        for (int i = 0; i < nums.length; i++) {
            add += i;
            add -= nums[i];
        }
        return add;
    }

    public static void main1(String[] args) {
        int[] arr = new int[]{0, 1};
        System.out.println(missingNumber(arr));
    }
}